This article focuses on Oracle databases. If the dual table in the Oracle database corresponds to DB2 SYSIBM in actual operations, but you do not know how to solve it correctly, so the following articles must be good teachers and friends for you.
SYSDUMMY1 table
DB2 solution: corresponding to the SYSIBM. SYSDUMMY1 ta
SYSIBM. SYSPACKSTMT tableThe SYSIBM. SYSPACKSTMT table contains one or more rows for each statement in a package.
Column name
Data Type
Description
Use
Location
VARCHAR (+) not NULL
Always contains blanks
S
Collid
VARCHAR (+) not NULL
Name of the Package collection.
G
name
varchar (+) not NULL
days of the year in which the reference is written.
SELECT to_char (sysdate, ' DDD ') from DUAL;
14gt. Returns the number of seconds between the time values specified in the midnight and the parameters:
SELECT to_char (sysdate, ' sssss ') from DUAL;
15gt: Returns the writing of the first weeks of the year in the parameters
SELECT to_char (sysdate, ' WW ') from DUAL;
DB2 can actually do this:
1gt: The writing method of the year in which the time is taken
SELECT year [current timestamp] from
Migration of DB2 database sequence 1. generate the following statement to obtain the current value of the source database sequence: www.2cto.com SQL code SELECT 'select' CREATE SEQUENCE '| seqname | 'start WITH ''' |' | seqname | '. nextval from sysibm. sysdummy1' FROM syscat. sequences WHERE seqtype ='s AND seqschema = CURRENT schema www.2cto.com 2. execute the SQL statement that generates the SEQUENCE of
Reposted from: longtang Bay
1.1.1 obtain the first N records
SQL Server: Select Top N * From xtable
ORACLE: Select * From xtable where rownum
DB2: Select * From xtable fetch first n rows only
1.1.2 obtain the current date
SQL Server: Select getdate ()
ORACLE: Select sysdate from dual
DB2: Select current timestamp from sysibm. sysdummy1
1.1.3 connection string
SQL Server: Select Hello + toone
ORACLE: Select
From: http://hi.baidu.com/emilypear/blog/item/6bd1b399bedacf0b6f068cb0.html
-- Create a custom single value type
Create distinct type var_newtype
As decimal (5, 2) with comparisons; -- var_newtype type name
-- Decimal (5, 2) actual type
-- Delete a custom single value type Drop distinct type var_newtype;
-- Create a custom data type Create type my_type (
Username varchar (20 ),
Department integer,
Salary decimal (10, 2 ))
Not final
Mode db2sql;
-- Modify the Data Type of the custom structu
): the number of seconds between midnight and arg.
Monthname (arg): returns the month name of arg.
Dayname (arg): returns the week of arg.
Common examples:
Returns the current system time.
Oracle: select sysdate from dual;
DB2: select current date from sysibm. sysdummy1
Returns the next day of the current time)
Oracle: select sysdate, sysdate + interval '1' day from dual;
DB2: select current date + 1 day fr
If you only get the dateSelect current_date from sysibm. sysdummy1 orSelect curdate () from sysibm. sysdummy1If you only get the time and the time precision is in secondsSelect current_time from sysibm. sysdummy1 orSelect curtime () from
1. Character functions:
The characters in SQL Server are case-insensitive.However, the lower and upper functions are common in SQL Server, Oracle, and DB2. For example, select empno, ename, deptno from EMP where upper (ename) = upper ('bucket ');
Example of connection characters:• SQL SERVER: Select 'good '+ 'string'
• ORACLE: Select Concat ('good', 'string') from dual;• DB2: Select Concat ('good', 'string') from sysibm.
DB2 time and date function 1. To use SQL to obtain the current date, time, and time stamp, see the appropriate DB2 register: www.2cto.com SELECT current date FROM sysibm. sysdummy1SELECT current time FROM sysibm. sysdummy1SELECT current timestamp FROM sysibm. sysdummy1 Description: ysibm. the
", "edwdba"; Create View "DM1 ". "partition" ("partition", "detail_customer_group_name", "customer_group_id", "customer_group_name", "show_order") as select distinct a0.cust _ tp_id limit, a0.cust _ tp_nm limit, case when a0.cust _ tp_id_1 = 8 then 200013 when a0.cus T_tp_id_1 = 7 then 200014 when a0.cust _ tp_id_1 = 6 then 200015 else 2000151 end as customer_group_id, a0.cust _ tp_nm_1 customer_group_name, case when hour _ hour = 8 then 1 when a0.cust _ tp_id_1 = 7 then 2 when a0.cust _ tp_id_1
DB2 time functions are one of our most common functions. The following describes some DB2 time functions for your reference. We hope you can learn more about DB2 time functions.
-- Get the current date:
Select current date from sysibm. sysdummy1;
Values current date;
-- Get the current date
Select current time from sysibm.
. sysdummy1;
---- Determine whether a table existsSelect count (*) into @ exists from syscat. tables where tabschema = current schema and tabname = 'zy _ processlog ';---- Obtain the first N recordsFETCH FIRST N ROWS ONLY---- Define the return valueDeclare rs0 cursor with return to caller for select 0 from sysibm. sysdummy1;Declare rs1 cursor with return to calle
Time addition and subtraction: Remember to keep up with the time types such as day and hour
Timestamp (timestamp (def_time) + 1 day) + 18 hour
DB2 time functions are one of our most common functions. The following describes some DB2 time functions for your reference. We hope you can learn more about DB2 time functions.
-- Get the current date:
Select current date from sysibm. sysdummy1;
DB2 time function statement [SQL] Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/-- > -- Get the current date: select current date from sysibm. sysdummy1; values current date; -- Obtain the current date select current time from sysibm. sysdummy1; values current time; --
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.